package com.qr.product.controller;


import com.qr.product.pojo.Product;
import com.qr.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("product")
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Product findById(@PathVariable("id") Integer id){
        Product byId = productService.findById(id);
        return byId;
    }


    @RequestMapping(method = RequestMethod.POST)
    public int saveById(@RequestBody Product product){
        int byId = productService.save(product);
        System.out.println("保存成功");
        return byId;
    }

}
